package com.hu.bgp.client.place;

import java.util.HashMap;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;

import com.hu.bgp.client.gin.BgpGinjector;
import com.hu.bgp.client.presenter.Presenter;
import com.hu.bgp.framework.clientapi.util.Firebug;

public abstract class Place
{
	protected URIconstants constants;
	private final HashMap<String, String> attributes = new HashMap<String, String>();
	//protected final BgpGinjector bgpInject = GWT.create(BgpGinjector.class);
	
	public Place(String state)
	{
		BgpGinjector gin = GWT.create(BgpGinjector.class);
		constants = gin.getURIconstants();
		//TODO:fixx uri parsing
		String att = state.substring(state.indexOf(constants.attributesSeperator())+1, state.length());

		String arr[] = att.split(constants.kvPairSeperator());
		
		
		for(int i =0;i< arr.length; i++){
			String t[] = arr[i].split(constants.keyValuaSeperator());
			try{
			attributes.put(t[0], t[1]);
			}catch (Exception e) {
				// ignored out of bounds etc..
			}
		}

	}
	public abstract String asURI();
	public HashMap<String, String> getAttributes()
	{
		return attributes;
	}
	
}
